{include file="public/header" /}
<style type="text/css">
    #des, #des input {
        width: 40px;
        text-align: center;
    }

    #id {
        width: 78px;
    }

    .bs-checkbox {
        width: 36px;
        height: 40px
    }

    .fixed-table-toolbar .columns, .fixed-table-toolbar .search {
        margin-left: 0px;
        margin-top: 0px
    }

    #title span {
        float: right;
    }

    .btn-active {
        background: #1ab394;
        color: #fff
    }
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        {include file="public/tophead"}
        {include file="public/top" /}
        <div class="ibox-content">
            <div class="row row-lg">

                <div style="display:block;clear: both;"></div>
                <div class="fixed-table-toolbar">

                </div>
                <div class="example">
                    <form class="form-horizontal" method="post">
                        <table data-toggle="table">
                            <thead>
                                <tr>
                                    <th data-align="center">ID</th>
                                    <th data-align="center">类型名称</th>
                                    <th data-align="center">排序</th>
                                    <th data-align="center">管理</th>
                                </tr>
                            </thead>
                            <tbody>
                            {volist name="data" id="vo"}
                            <tr id="id{$vo.id}">

                                <td>{$vo.id}</td>
                                <td>{$vo.name}</td>
                                <td>{$vo.sort}</td>



                                <td>
                                    <div class="btn-group">
                                        <div data-toggle="dropdown" class="btn btn-primary btn-xs dropdown-toggle">
                                            操作 <span class="caret"></span>
                                        </div>
                                        <ul class="dropdown-menu">

                                            <li><a onclick="add('{:url('report/typeAdd', ['id' => $vo['id']])}','‘{$vo.name}’修改')">修改</a></li>

                                        </ul>
                                    </div>
                                </td>
                            </tr>
                            {/volist}
                            </tbody>
                        </table>
                    </form>
                </div>
            </div>
            <hr>
            <div class="row row-lg">
                <div class="col-sm-12 pages">{$page|raw}</div>
            </div>
    </div>
</div>
{include file="public/footer" /}
{load href="__STYLE__/admin/plugins/bootstrap/bootstrap-table.min.css"}
{load href="__STYLE__/admin/plugins/bootstrap/bootstrap-table.min.js"}
{load href="__STYLE__/admin/plugins/bootstrap/bootstrap-table-zh-CN.min.js"}
<script type="text/javascript">
$(document).ready(function () {
    $("#changeAll").click(function () {
        if ($("#changeAll").prop('checked')) {
            $("table input[type='checkbox']").prop('checked', true);
        } else  {
            $("table input[type='checkbox']").prop('checked', false);
        }
    });
    $("#operateAll").click(function () {
        var ids = '', type = $("#operateType").val();
        $("table input[type='checkbox']").each(function () {
           if ($(this).prop('checked')){
               if (ids) ids += ',';
               ids += $(this).val();
           }
        });
        if (! ids) {
            layer.msg('请选择内容！', {icon: 5, time: 3000});
            return;
        }
        $.ajax({
            url: "{:url('batchOperate')}",
            type: 'POST',
            dataType: 'JSON',
            data: {ids: ids, type: type},
            success: function (res) {
                if (res.status) {
                    layer.msg(res.msg, {icon:6, time: 2500}, function () {
                        window.location.reload();
                    });
                    return;
                }
                layer.msg(res.msg, {icon: 5, time: 3000});
            },
            error: function () {
                layer.msg('网络错误！', {icon: 2, time: 3000});
            }
        });
    });
});


function del(id){
    swal_del(id,"{:url('del')}", {title: '该内容'})
}
function audit(id, type) {
    $.ajax({
        url: "{:url('content/audit')}",
        type: 'POST',
        dataType: 'JSON',
        data: {id: id, type: type},
        success: function (res) {
            if (res.status == 1) {
                layer.msg(res.msg, {icon: 1, time: 2500}, function () {
                    window.location.reload();
                });
            } else  {
                layer.msg(res.msg, {icon: 5, time: 3000});
            }
        },
        error: function () {
            layer.msg('网络错误', {icon: 2, time: 3000});
        }
    });
}
</script>